package com.guomao.function;

import java.util.function.Supplier;

public class SupplierDemo {

    public static void main(String[] args) {

/*        String s1 = getString(new Supplier<String>() {
            @Override
            public String get() {
                return "Hello world";
            }
        });*/


//        String s1 = getString(()->{return "Hello world";});
//        String s1 = getString(() -> "Hello world");
//        Integer i1 = getInteger(() -> 199);


        int[] arr = {1, 20, 3, 4, 56, 6, 79, 8, 9, 10};

        int result = getMax(() -> {
            int max = arr[0];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] > max) {
                    max = arr[i];
                }
            }
            return max;
        });

        System.out.println(result);

    }


    public static int getMax(Supplier<Integer> s) {
        return s.get();
    }


    public static String getString(Supplier<String> s) {
        return s.get();
    }


    public static Integer getInteger(Supplier<Integer> s) {
        return s.get();
    }

}
